package org.perla.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "attitude")
@NamedQueries({
    @NamedQuery(name = "Attitude.findAll", query = "SELECT a FROM Attitude a"),
    @NamedQuery(name = "Attitude.findByIdNodo", query = "SELECT a FROM Attitude a WHERE a.attitudePK.idNodo = :idNodo"),
    @NamedQuery(name = "Attitude.findByTimestamp", query = "SELECT a FROM Attitude a WHERE a.attitudePK.timestamp = :timestamp"),
    @NamedQuery(name = "Attitude.findByAttitudeX", query = "SELECT a FROM Attitude a WHERE a.attitudeX = :attitudeX"),
    @NamedQuery(name = "Attitude.findByAttitudeY", query = "SELECT a FROM Attitude a WHERE a.attitudeY = :attitudeY"),
    @NamedQuery(name = "Attitude.findByAttitudeZ", query = "SELECT a FROM Attitude a WHERE a.attitudeZ = :attitudeZ"),
    @NamedQuery(name = "Attitude.findByIdSensore", query = "SELECT a FROM Attitude a WHERE a.attitudePK.idSensore = :idSensore")})
public class Attitude implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AttitudePK attitudePK;
    @Basic(optional = false)
    @Column(name = "attitudeX")
    private short attitudeX;
    @Basic(optional = false)
    @Column(name = "attitudeY")
    private short attitudeY;
    @Basic(optional = false)
    @Column(name = "attitudeZ")
    private short attitudeZ;

    public Attitude() {
    }

    public Attitude(AttitudePK attitudePK) {
        this.attitudePK = attitudePK;
    }

    public Attitude(AttitudePK attitudePK, short attitudeX, short attitudeY, short attitudeZ) {
        this.attitudePK = attitudePK;
        this.attitudeX = attitudeX;
        this.attitudeY = attitudeY;
        this.attitudeZ = attitudeZ;
    }

    public Attitude(String idNodo, long timestamp, String idSensore) {
        this.attitudePK = new AttitudePK(idNodo, timestamp, idSensore);
    }

    public AttitudePK getAttitudePK() {
        return attitudePK;
    }

    public void setAttitudePK(AttitudePK attitudePK) {
        this.attitudePK = attitudePK;
    }

    public short getAttitudeX() {
        return attitudeX;
    }

    public void setAttitudeX(short attitudeX) {
        this.attitudeX = attitudeX;
    }

    public short getAttitudeY() {
        return attitudeY;
    }

    public void setAttitudeY(short attitudeY) {
        this.attitudeY = attitudeY;
    }

    public short getAttitudeZ() {
        return attitudeZ;
    }

    public void setAttitudeZ(short attitudeZ) {
        this.attitudeZ = attitudeZ;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (attitudePK != null ? attitudePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Attitude)) {
            return false;
        }
        Attitude other = (Attitude) object;
        if ((this.attitudePK == null && other.attitudePK != null) || (this.attitudePK != null && !this.attitudePK.equals(other.attitudePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.perla.entities.Attitude[attitudePK=" + attitudePK + "]";
    }

}
